<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link type="text/css" rel="stylesheet" href="css/login.css"/>
    <script type="text/javascript" src="js/jquery-1.12.4.min.js"></script>
    <script type="text/javascript" src="js/login.js"></script>
    <script>
        var uid;

        $(document).ready(function () {
            var constPhone = sessionStorage.getItem('phone');

            $.get("resume/selectUser", {"phone": constPhone}, function (u) {
                uid = u.id;
            })

            $.get("resume/select", {"phone": constPhone}, function (resume) {
                if (resume) {
                    // 回显简历信息
                    $("input[name='name']").val(resume.name);
                    $(".sex").removeClass("on"); // 清除以前的性别选择
                    if (resume.sex === "男") {
                        $(".sex").eq(0).addClass("on"); // 男性
                    } else {
                        $(".sex").eq(1).addClass("on"); // 女性
                    }
                    $("input[name='birthaddress']").val(resume.birthAddress);
                    $("input[name='phone']").val(resume.phone);
                    $("input[name='school']").val(resume.school);
                    $("#degree").val(resume.degree); // 学历
                    $("input[name='professName']").val(resume.professName);
                    $("input[name='major']").val(resume.major);
                    $("#expectedAddress").val(resume.expectedAddress);
                    $("#sal").val(resume.sal);
                    $("#work").val(resume.work);
                    $("#jobStatus").val(resume.jobStatus);
                    $("input[name='email']").val(resume.email);

                    $("[name='生成简历']").click(function () {
                        var resumeData = getResumeData();
                        $.get("resume/update",{
                            "uid": uid,
                            "name": resumeData.name,
                            "sex": resumeData.sex,
                            "birthAddress": resumeData.birthAddress,
                            "phone": resumeData.phone,
                            "school": resumeData.school,
                            "degree": resumeData.degree,
                            "professName": resumeData.professName,
                            "major": resumeData.major,
                            "expectedAddress": resumeData.expectedAddress,
                            "sal": resumeData.sal,
                            "work": resumeData.work,
                            "jobStatus": resumeData.jobStatus,
                            "email": resumeData.email
                        },function (response) {
                            if(response) {
                                alert("修改成功")
                            } else {
                                alert("修改失败")
                            }
                        })
                    })

                } else {
                    $("[name='生成简历']").click(function () {
                        var resumeData = getResumeData();
                        $.get("resume/add", {
                            "uid": uid,
                            "name": resumeData.name,
                            "sex": resumeData.sex,
                            "birthAddress": resumeData.birthAddress,
                            "phone": resumeData.phone,
                            "school": resumeData.school,
                            "degree": resumeData.degree,
                            "professName": resumeData.professName,
                            "major": resumeData.major,
                            "expectedAddress": resumeData.expectedAddress,
                            "sal": resumeData.sal,
                            "work": resumeData.work,
                            "jobStatus": resumeData.jobStatus,
                            "email": resumeData.email
                        }, function (response) {
                            if (response) {
                                alert("生成成功")
                            } else {
                                alert("生成失败")
                            }
                        })
                    })
                }
            })
            var getResumeData = function () {
                var resumeData = {
                    name: $("input[name='name']").val(),
                    sex: $(".sex.on").text(), // 选择性别
                    birthAddress: $("input[name='birthaddress']").val(),
                    phone: $("input[name='phone']").val(),
                    school: $("input[name='school']").val(),
                    degree: $("#degree").val(), // 学历
                    professName: $("input[name='professName']").val(),
                    major: $("input[name='major']").val(),
                    expectedAddress: $("#expectedAddress").val(),
                    sal: $("#sal").val(),
                    work: $("#work").val(),
                    jobStatus: $("#jobStatus").val(),
                    email: $("input[name='email']").val()
                };
                return resumeData;
            };
        })


    </script>
    <title>简历</title>
</head>

<body>
<div class="header">
    <div class="mainwarp">
        <div class="logo"><a href="../../../../target/classes/public/index.html"><img src="images/log.png"/></a></div>
        <div class="welcome">欢迎注册</div>
        <div class="headerright">
            <a href="login.html">个人登录</a>
            <span>|</span>
            <a href="../../../../target/classes/public/index.html">返回首页</a>
        </div>
    </div>
</div>
<div class="jianliBox">
    <div class="jlpart1">
        <img src="images/img1.png"/>
    </div>
    <div class="jlpart2">
        <div class="jlpart2_1">
            <div class="jlbox1">
                <h1>一分钟填写简历</h1>
                <p>填写以下信息即可生成一份简历，一步注册，起航你的成功之梦！</p>
            </div>
            <div class="jlbox2">
                <span class="tit">姓名</span>
                <input name="name" type="text" class="txtcon txt1"/>
            </div>
            <div class="jlbox2">
                <span class="tit">我是</span>
                <div class="sex on">男</div>
                <div class="sex">女</div>
                <div class="clear"></div>
            </div>
            <div class="jlbox2">
                <span class="tit">出生于</span>
                <input name="birthaddress" type="text" class="txtcon txt3"/>
                <div class="clear"></div>
            </div>
            <div class="jlbox2">
                <span class="tit">手机号</span>
                <input name="phone" type="text" class="txtcon txt3"/>
                <div class="clear"></div>
            </div>
            <div class="jlbox2">
                <span class="tit">毕业学校</span>
                <input name="school" type="text" class="txtcon txt3"/>
                <select class="txtcon txt5" id="degree">
                    <option value="初中及一下">初中及一下</option>
                    <option value="中专/中技">中专/中技</option>
                    <option value="高中">高中</option>
                    <option value="大专">大专</option>
                    <option value="硕士">硕士</option>
                    <option value="本科">本科</option>
                    <option value="博士">博士</option>
                </select>
                <div class="titxt">学历</div>
                <div class="clear"></div>
            </div>
            <div class="jlbox2">
                <span class="tit">专业名称</span>
                <input name="professName" type="text" class="txtcon txt3"/>
                <div class="clear"></div>
            </div>
            <div class="jlbox2">
                <span class="tit">所学专业</span>
                <input name="major" type="text" class="txtcon txt3"/>
                <div class="clear"></div>
            </div>
            <div class="jlbox2">
                <span class="tit">想在</span>
                <select class="txtcon txt5" id="expectedAddress">
                    <option value="北京">北京</option>
                    <option value="上海">上海</option>
                    <option value="深圳">深圳</option>
                    <option value="广州">广州</option>
                    <option value="长春">长春</option>
                </select>
                <div class="titxt">找月薪</div>
                <select class="txtcon txt6" id="sal">
                    <option value="30000以上">30000以上</option>
                    <option value="20000-30000">20000-30000</option>
                    <option value="10000-20000">10000-20000</option>
                    <option value="5000-10000">5000-10000</option>
                    <option value="5000以下">5000以下</option>
                </select>
                <div class="titxt">的</div>
                <select class="txtcon txt5" id="work">
                    <option value="全职">全职</option>
                    <option value="兼职">兼职</option>
                    <option value="实习">实习</option>
                </select>
                <div class="titxt">工作</div>
                <div class="clear"></div>
            </div>
            <div class="jlbox2">
                <span class="tit">求职状态</span>
                <select class="txtcon txt2" id="jobStatus">
                    <option value="离职-随时到岗">离职-随时到岗</option>
                    <option value="在职-月内到岗">在职-月内到岗</option>
                    <option value="在职-考虑机会">在职-考虑机会</option>
                    <option value="在职-暂不考虑">在职-暂不考虑</option>
                </select>
            </div>
            <div class="jlbox2">
                <span class="tit">邮箱</span>
                <input name="email" type="text" class="txtcon txt3"/>
                <div class="clear"></div>
            </div>
            <div class="jlbox2">
                <input name="生成简历" type="button" value="生成简历" class="jlbtn"/>
            </div>
        </div>
    </div>
</div>

<div class="clear"></div>
<div class="footer">
</div>
</body>
</html>
